<template>
  <div
    class="new-page resource-tool-main resource-tool-page"
    :style="
      `height: ${pageMinHeight +
        95}px;width: calc(100% - ${sideMenuWidth} - 33px)`
    "
  >
    <div v-for="item in allArr" :key="item.title">
      <template v-if="getPre(item.title)">
        <div class="rt-title d-flex ai-center">
          <span class="fs-14 fw-b text-color-21252e">{{ item.title }}</span>
        </div>
        <div class="pp-item-box mb-15">
          <template v-for="cItem in item.children">
            <div
              v-if="getPre(cItem.role)"
              :key="cItem.title"
              class="pp-item-li"
              @click="clickHandler(cItem)"
            >
              <div class="pp-item-li-in">
                <a-row :gutter="8">
                  <a-col :span="4">
                    <a-icon
                      class="rms-icon"
                      :component="cItem.icon"
                      style="font-size:32px"
                    />
                  </a-col>
                  <a-col :span="19">
                    <div class="fw-b fs-14 text-color-21252e">
                      {{ cItem.title }}
                    </div>
                    <div class="text-color-505363 fs-14">{{ cItem.des }}</div>
                  </a-col>
                </a-row>
              </div>
            </div>
          </template>
        </div>
      </template>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex';
import { presOpen } from '@/utils/pres';
import management_Service from '@/assets/icon/management_Service.svg';
import management_Configure from '@/assets/icon/management_Configure.svg';
import management_Data_sheet from '@/assets/icon/management_Data_sheet.svg';
import management_Email from '@/assets/icon/management_Email.svg';
import management_Monitor from '@/assets/icon/management_Monitor.svg';
import management_Setting from '@/assets/icon/management_Setting.svg';
import management_Template from '@/assets/icon/management_Template.svg';
export default {
  data() {
    return {
      allArr: Object.freeze([
        {
          title: '工具',
          key: 'tools',
          children: [
            {
              icon: management_Service,
              pathName: '事件代码维护',
              title: '事件代码维护',
              role: '事件代码维护',
              des: '查看和管理由事件触发的报文'
            },

            {
              icon: management_Service,
              pathName: 'ALERT代码维护',
              title: 'ALERT代码维护',
              role: 'ALERT代码维护',
              des: '查看和管理由事件触发的报文'
            },
            {
              icon: management_Service,
              pathName: 'ATA章节维护',
              title: 'ATA章节维护',
              role: 'ATA章节维护',
              des: '查看和维护ATA章节'
            },
            {
              icon: management_Service,
              path: 'eventHistorySub',
              title: '故障历史',
              role: '故障历史',
              des: '查看故障历史'
            },
            {
              icon: management_Service,
              pathName: '历史故障统计',
              title: '历史故障统计',
              role: '历史故障统计',
              des: '查看历史故障统计'
            },
            {
              icon: management_Service,
              pathName: '在翼发动机及APU信息',
              title: '在翼发动机及APU信息',
              des: '查看在翼发动机及APU信息',
              role: '邮件通知/ahm提醒应用'
            }

            // {
            //   icon: '',
            //   pathName: '故障代码维护',
            //   title: '故障代码维护',
            //   des: '查看和管理故障代码'
            // },
          ]
        },
        {
          title: '勤务',
          key: 'service',
          children: [
            {
              icon: management_Setting,
              pathName: '勤务管理设置',
              title: '勤务管理设置',
              role: '勤务管理设置',
              des: '配置勤务警报的触发条件'
            },
            {
              icon: management_Data_sheet,
              pathName: '勤务信息',
              title: '勤务信息',
              role: '勤务信息',
              des: '查看整个机队勤务项目的图表数据'
            },

            {
              icon: management_Monitor,
              pathName: '机队监控',
              title: '机队监控',
              role: '机队监控',
              des: '启动机队监控查看”弹出式“故障通知'
            }
          ]
        },
        {
          title: '报文推送工作台',
          key: 'packetPush',
          children: [
            {
              icon: management_Service,
              pathName: '事件触发报文上传',
              title: '事件触发报文上传',
              role: '事件触发报文上传',
              des: '查看和管理由事件触发的报文'
            },
            {
              icon: management_Template,
              pathName: '上行报文模板管理',
              title: '上行模板库',
              role: '上行模板库',
              des: '编辑和配置上行报文的模板'
            },
            {
              icon: management_Configure,
              pathName: '模板管理',
              title: '报文模板设置',
              role: '报文模板设置',
              des: 'ACARS报文解码模板和展示模板邮件'
            }
          ]
        },
        {
          title: '邮件',
          key: 'mail',
          children: [
            {
              icon: management_Email,
              pathName: '邮件通知',
              title: '邮件通知',
              role: '邮件通知/ahm提醒应用',
              des: '按指定条件触发邮件通知'
            }
          ]
        },
        {
          title: '设置',
          key: 'mail',
          children: [
            {
              icon: management_Service,
              pathName: '用户',
              title: '用户',
              role: '用户列表',
              des: '用户列表'
            },
            {
              icon: management_Service,
              pathName: '角色',
              title: '角色',
              role: '角色',
              des: '角色列表'
            },
            {
              icon: management_Service,
              pathName: '事件管控',
              title: '事件管控',
              role: '角色',
              des: '事件管控状态控制'
            },
            {
              icon: management_Service,
              pathName: '提示音',
              title: '提示音',
              role: '角色',
              des: '提示音设置'
            },
            {
              icon: management_Service,
              pathName: 'AHM Benefit信息维护',
              title: 'AHM Benefit信息维护',
              role: '角色',
              des: '信息维护'
            },
            // {
            //   icon: management_Service,
            //   pathName: '用户与飞机关系',
            //   title: '用户与飞机关系',
            //   role: '用户与飞机关系',
            //   des: '用户与飞机关系列表'
            // }
          ]
        }
      ])
    };
  },
  computed: {
    ...mapGetters('setting', ['sideMenuWidth']),
    ...mapGetters('user', ['userInfo']),
    ...mapState('setting', ['pageMinHeight']),
    userMenu() {
      return this.userInfo?.menus ?? [];
    }
  },
  methods: {
    getPre(role = '') {
      if (!presOpen) {
        return true;
      } else {
        return this.userMenu?.findIndex(um => um?.title === role) > -1 ?? false;
      }
    },
    clickHandler(item) {
      if (item.pathName) {
        this.$router.push({ name: item.pathName });
      } else if (item.path) {
        this.$router.push({ path: item.path });
      }
    }
  }
};
</script>

<style lang="less">
@import './index.less';
</style>
